from concordion.annotation import ExpectedToFail
from FunctionalAbstract import FunctionalTest

@ExpectedToFail
class CreateStoryTest(FunctionalTest):

	def empty_story_visible(self):
		try:
			self.driver.find_element_by_id("empty_story")
			self.driver.find_element_by_id("new_story_title")
			self.driver.find_element_by_id("new_story_description")
		except:
			return False
		return True

	def fill_story(self, title, description):
		self.driver.find_element_by_id("new_story_title").send_keys(title)
		self.driver.find_element_by_id("new_story_description").send_keys(description)

	def has_story(self, title, description):
		stories = self.driver.find_elements_by_xpath("//div[@class='story']")
		for story in stories:
			if story.find_element_by_id("story_title").get_value() == title \
				and story.find_element_by_id("story_description").get_value() == description:
				return True
		return False
